<?php



namespace App\Services\Business\Models;

use App\Services\Member\Models\User;
use App\Services\Shop\Models\Shop;
use Illuminate\Database\Eloquent\Model;

class MediaVideo extends Model
{
    protected $table = 'media_videos';

    protected $fillable = [
        'title', 'shop_id','thumb', 'duration', 'size',
         'aliyun_video_id','duration','url','path',
        'transcode_status', 'ref_count','favorite_count','review_count','thumbsup_count','comments_count',
        'category_id','user_id','is_open'
    ];

    protected $appends = [
        'size_mb'
    ];

    public function getSizeMbAttribute()
    {
        return round($this->size / 1024 / 1024, 2);
    }
    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }
    public function thumbsups()
    {
        return $this->morphMany(ThumbsUp::class, 'thumbsupable');
    }


    public function comments()
    {
        return $this->morphMany(Comment::class, 'commentable');
    }
    public function favorites()
    {
        return $this->morphMany(Favorite::class, 'favorable');
    }

}
